﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Odebrecht.WpfApplication
{
    public class CustomCellTemplate : DataTemplateSelector
    {
        #region Methods

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            return base.SelectTemplate(item, container);
        }

        #endregion Methods
    }

    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        #region Constructors

        public Window1()
        {
            InitializeComponent();

            var dataGridTemplateColumn = new DataGridTemplateColumn();

            dataGridTemplateColumn.CellTemplateSelector = new DataTemplateSelector();

            dataGridTemplateColumn.CellTemplate = new DataTemplate();

            var dataGrid = new DataGrid();

            dataGrid.Columns.Add(dataGridTemplateColumn);

            dataGrid.SelectedCellsChanged += dataGrid_SelectedCellsChanged;
        }

        #endregion Constructors

        #region Methods

        void dataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            var item = e.AddedCells[0].Item;
        }

        private void OnGotFocus(object sender, System.Windows.RoutedEventArgs e)
        {
            // TODO: Add event handler implementation here.
        }

        #endregion Methods
    }
}